﻿/*
 * GateController.cs
 * 
 * 闸杆控制器
 * 
 * By developer_ken
 */

using System;
using System.Collections.Generic;
using System.Device.Gpio;
using System.Text;

namespace SmGateDemo
{
    public class GateController : ISensor
    {
        GpioController GPIO;
        const int PIN_POSGREEN = 36;
        const int PIN_POSRED = 40;
        const int PIN_POSYELLOW = 38;
        public GateController()
        {

        }
        public void Init()
        {
//#if RELEASE
            GPIO = new GpioController(PinNumberingScheme.Board);
            GPIO.OpenPin(PIN_POSGREEN, PinMode.Output);
            GPIO.OpenPin(PIN_POSRED, PinMode.Output);
            GPIO.OpenPin(PIN_POSYELLOW, PinMode.Output);
            AllNegative();
            GPIO.Write(PIN_POSYELLOW, PinValue.High);
//#endif
        }

        public void Open()
        {
//#if RELEASE
            AllNegative();
            GPIO.Write(PIN_POSGREEN, PinValue.High);
//#endif
        }

        public void Close()
        {
//#if RELEASE
            AllNegative();
            GPIO.Write(PIN_POSRED, PinValue.High);
//#endif
        }

        public void AllNegative()
        {
//#if RELEASE
            GPIO.Write(PIN_POSGREEN, PinValue.Low);
            GPIO.Write(PIN_POSRED, PinValue.Low);
            GPIO.Write(PIN_POSYELLOW, PinValue.Low);
//#endif
        }
    }
}
